<%--
  Created by IntelliJ IDEA.
  User: HUYUZHU
  Date: 2020/1/9
  Time: 13:20
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:choose>
    <%--搜索结果为0时    --%>
    <c:when test="${recordNum==0}">
        <div class="resource-post-box pb-25">
            <span style="color: darkgray" class="font-text">
            没有找到相关资源
            </span>
            <span id="search-criteria" style="float:right;color: darkgray" class="font-text"><a
                    style="text-decoration:none" href="javascript:void(0);"
                    onclick="clickCriteria(1,1)">展开搜索条件</a></span>
        </div>
        <div id="search-criteria-text" class="resource-post-box" style="display: none">
            <c:if test="${!queryStr.equals('') and queryStr!=null}">
                <div class="col-md-12 row mnt-7" style="display:block">
                    <a class=re-btn" disabled="disabled"
                       style="padding-left: 0px; pointer-events: none; background-color:white; color:#1b1b1b; font-weight: 400; font-size:1rem;">搜索</a>
                    <button class="re-btn"
                            style="margin-right:10px;background-color: rgba(247, 247, 247, 0.8);color: #7a7a7a;pointer-events: none;">${queryStr}</button>
                </div>
                <br/>
            </c:if>
            <c:if test="${!searchGroupNames.equals('') and searchGroupNames!=null}">
                <div class="col-md-12 row" style="margin-top: -10px;display:block">
                    <a class="re-btn" disabled="disabled"
                       style="padding-left: 0px; pointer-events: none; background-color:white; color:#1b1b1b; font-weight: 400; font-size:1rem;">群组</a>
                    <c:forEach var="searchGroupNames" items="${searchGroupNames.split(',')}">
                        <button class="re-btn"
                                style="margin-right:5px;background-color: rgba(247, 247, 247, 0.8);color: #7a7a7a;pointer-events: none;">${searchGroupNames.trim()}</button>
                    </c:forEach>
                </div>
                <br/>
            </c:if>
            <c:if test="${!searchLabelInfos.equals('') and searchLabelInfos!=null}">
                <c:forEach items="${searchLabelInfos}" var="labelInfoList" varStatus="labelInfoListStatus" >
                    <div class="col-md-12 row" style="margin-top: -10px;display:block">
                        <a class="re-btn" disabled="disabled"
                           style="padding-left: 0px; pointer-events: none; background-color:white; color:#1b1b1b; font-weight: 400; font-size:1rem;">
                                ${labelInfoList.get(0).get("labelName")}
                        </a>
                        <c:forEach items="${labelInfoList}" var="labelInfo" varStatus="labelInfoStatu" begin="1">
                            <button class="re-btn"
                                    style="margin-right:5px;background-color: rgba(247, 247, 247, 0.8);color: #7a7a7a;pointer-events: none;">${labelInfo.get("labelName")}</button>
                        </c:forEach>
                    </div>
                    <br/>
                </c:forEach>
            </c:if>
            <div class="col-md-12 row" style="margin-top: -10px;">
                <button class="re-btn" type="submit" onclick="searchAgain('${queryStr}','${groupIds}','${labelIds}')"><a>重新搜索</a>
                </button>
            </div>
        </div>
    </c:when>
    <%--有搜索结果时    --%>
    <c:otherwise>
        <div class="resource-post-box pt-30 pb-30" id="firstrows">
            <span style="margin-right:5px;color: darkgray" class="font-text">找到 ${recordNum} 个相关资源</span>
            <span id="search-criteria1" style="float:right;color: darkgray" class="font-text"><a href="javascript:void(0);" onclick="clickCriteria(1,2)">展开搜索条件</a></span>
        </div>
        <div id="search-criteria-text1" class="resource-post-box" style="display: none">
            <c:if test="${!queryStr.equals('') and queryStr!=null}">
                <div class="col-md-12 row" style="margin-top: -10px;display:block">
                    <a class="re-btn" disabled="disabled"
                       style="padding-left: 0px; pointer-events: none; background-color:white; color:#1b1b1b; font-weight: 400; font-size:1rem;">搜索</a>
                    <button class="re-btn"
                            style="margin-right:10px;background-color: rgba(247, 247, 247, 0.8);color: #7a7a7a;pointer-events: none;">${queryStr}</button>
                </div>
                <br/>
            </c:if>
            <c:if test="${!searchGroupNames.equals('') and searchGroupNames!=null}">
                <div class="col-md-12 row" style="margin-top: -10px;display:block">
                    <a class="re-btn" disabled="disabled"
                       style="padding-left: 0px; pointer-events: none; background-color:white; color:#1b1b1b; font-weight: 400; font-size:1rem;">群组</a>
                    <c:forEach var="searchGroupNames" items="${searchGroupNames.split(',')}">
                        <button class="re-btn"
                                style="margin-right:5px;background-color: rgba(247, 247, 247, 0.8);color: #7a7a7a;pointer-events: none;">${searchGroupNames.trim()}</button>
                    </c:forEach>
                </div>
                <br/>
            </c:if>
            <c:if test="${!searchLabelInfos.equals('') and searchLabelInfos!=null}">
                <c:forEach items="${searchLabelInfos}" var="labelInfoList" varStatus="labelInfoListStatus" >
                    <div class="col-md-12 row" style="margin-top: -10px;display:block">
                        <a class="re-btn" disabled="disabled"
                           style="padding-left: 0px; pointer-events: none; background-color:white; color:#1b1b1b; font-weight: 400; font-size:1rem;">
                                ${labelInfoList.get(0).get("labelName")}
                        </a>
                        <c:forEach items="${labelInfoList}" var="labelInfo" varStatus="labelInfoStatu" begin="1">
                            <button class="re-btn"
                                    style="margin-right:5px;background-color: rgba(247, 247, 247, 0.8);color: #7a7a7a;pointer-events: none;">${labelInfo.get("labelName")}</button>
                        </c:forEach>
                    </div>
                    <br/>
                </c:forEach>
            </c:if>
            <div class="col-md-12 row" style="margin-top: -10px;">
                <button class="re-btn" type="submit" onclick="searchAgain('${queryStr}','${groupIds}','${labelIds}')"><a>重新搜索</a>
                </button>
            </div>
        </div>
        <div class="re-resource-table re-resource-table-default">
            <table class="re-resource-table re-resource-table-default">
                <tbody id="result-column">
                <c:forEach var="app" items="${resourceESList}">
                    <tr>
                        <c:if test="${app.text == null}">
                            <th scope="row" style="padding-right: 50px" class="re-resource-table-topics">
                                <span style="margin-right: 10px"><a class="font-2" href="<%=request.getContextPath()%>/resource/resource?id=${app.id}" target="_blank">${app.title}</a></span>
                                <c:if test="${!app.label_name.equals(\"该资源无标签\")}">
                                <span style="float:right">
                                    <c:forEach var="label" items="${app.label_name.split(',|，')}" varStatus="s">
                                        <c:choose>
                                            <c:when test="${s.last}">
                                                <span style="color: darkgray" class="font-text"><a class="link-darkgray" href="../labels/labels?id=${label.trim()}">${label.trim()}</a>&nbsp;</span>
                                            </c:when>
                                            <c:otherwise>
                                                <span style="color: darkgray" class="font-text"><a class="link-darkgray" href="../labels/labels?id=${label.trim()}">${label.trim()}</a>&nbsp;&nbsp;/&nbsp;&nbsp;</span>
                                            </c:otherwise>
                                        </c:choose>
                                    </c:forEach>
                                </span>
                                </c:if>
                                <br>
                                <span class="font-text" style="color: darkgray"><a href="/myresource?userId=${app.user_id}" style="color: darkgray">${app.user_name}</a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="font-text" style="color: darkgray">
                                <fmt:formatDate value="${app.create_time}" pattern="yyyy-MM-dd HH:mm"/>
                                </span>
                                <c:if test="${!app.group_name.equals(\"该资源无群组\")}">
                                    <span style="float:right">
                                        <c:forEach var="groupName" items="${app.group_name.split(',|，')}" varStatus="gn">
                                            <c:forEach var="groupId" items="${app.group_id.split(',|，')}" varStatus="gi">
                                                <c:if test="${gn.index==gi.index}">
                                                    <c:choose>
                                                        <c:when test="${gn.last}">
                                                            <span style="color: darkgray" class="font-text"><a class="link-darkgray" href="../groupinfo?groupid=${groupId.trim()}">${groupName.trim()}</a>&nbsp;</span>
                                                        </c:when>
                                                        <c:otherwise>
                                                            <span style="color: darkgray" class="font-text"><a class="link-darkgray" href="../groupinfo?groupid=${groupId.trim()}">${groupName.trim()}</a>&nbsp;&nbsp;/&nbsp;&nbsp;</span>
                                                        </c:otherwise>
                                                    </c:choose>
                                                </c:if>
                                            </c:forEach>
                                        </c:forEach>
                                    </span>
                                </c:if>
                            </th>
                        </c:if>
                        <c:if test="${app.text != null}">
                            <th scope="row" style="padding-right: 50px" class="re-resource-table-topics">
                                <span style="margin-right: 10px"><a class="font-2" href="<%=request.getContextPath()%>/resource/resource?id=${app.id}" target="_blank">${app.title}</a></span>
                                <c:if test="${!app.label_name.equals(\"该资源无标签\")}">
                                    <span style="float:right">
                                        <c:forEach var="label" items="${app.label_name.split(',|，')}" varStatus="s">
                                            <c:choose>
                                                <c:when test="${s.last}">
                                                    <span style="color: darkgray" class="font-text"><a class="link-darkgray" href="../labels/labels?id=${label.trim()}">${label.trim()}</a>&nbsp;</span>
                                                </c:when>
                                                <c:otherwise>
                                                    <span style="color: darkgray" class="font-text"><a class="link-darkgray" href="../labels/labels?id=${label.trim()}">${label.trim()}</a>&nbsp;&nbsp;/&nbsp;&nbsp;</span>
                                                </c:otherwise>
                                            </c:choose>
                                        </c:forEach>
                                    </span>
                                </c:if>
                                <br>
                                <c:if test="${app.text.length() > 150}">
                                    <span class="font-text"
                                          style="word-break: break-all">${app.text.substring(0,150)}……</span>
                                </c:if>
                                <c:if test="${app.text.length() <= 150}">
                                    <span class="font-text" style="word-break: break-all">${app.text}</span>
                                </c:if>
                                <c:if test="${app.text != null || app.userId != null}">
                                    <br>
                                </c:if>
                                <span class="font-text" style="color: darkgray"><a href="/myresource?userId=${app.user_id}" style="color: darkgray">${app.user_name}</a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="font-text" style="color: darkgray">
                                    <fmt:formatDate value="${app.create_time}" pattern="yyyy-MM-dd HH:mm"/>
                                </span>
                                <c:if test="${!app.group_name.equals(\"该资源无群组\")}">
                                    <span style="float:right">
                                        <c:forEach var="groupName" items="${app.group_name.split(',|，')}" varStatus="gn">
                                            <c:forEach var="groupId" items="${app.group_id.split(',|，')}" varStatus="gi">
                                                <c:if test="${gn.index==gi.index}">
                                                    <c:choose>
                                                        <c:when test="${gn.last}">
                                                            <span style="color: darkgray" class="font-text"><a class="link-darkgray" href="../groupinfo?groupid=${groupId.trim()}">${groupName.trim()}</a>&nbsp;</span>
                                                        </c:when>
                                                        <c:otherwise>
                                                            <span style="color: darkgray" class="font-text"><a class="link-darkgray" href="../groupinfo?groupid=${groupId.trim()}">${groupName.trim()}</a>&nbsp;&nbsp;/&nbsp;&nbsp;</span>
                                                        </c:otherwise>
                                                    </c:choose>
                                                </c:if>
                                            </c:forEach>
                                        </c:forEach>
                                    </span>
                                </c:if>
                            </th>
                        </c:if>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </c:otherwise>
</c:choose>
<input id="pageSize" type="hidden" value="${pageSize}"/>
<input id="appNum" type="hidden" value="${recordNum}"/>
